<template>
  <el-table :data="list" style="width: 100%;padding-top: 15px;">
    <el-table-column label="玩家ID" show-overflow-tooltip>
      <template slot-scope="scope">
        {{scope.row.order_no}}
      </template>
    </el-table-column>
    <el-table-column label="玩家昵称" width="195" align="center">
      <template slot-scope="scope">
        {{scope.row.name}}
      </template>
    </el-table-column>
    <el-table-column label="充值金额" width="195" align="center">
      <template slot-scope="scope">
        ¥{{scope.row.price | toThousandslsFilter}}
      </template>
    </el-table-column>
    <el-table-column label="最后一次充值时间" width="220" align="center">
      <template slot-scope="scope">
        {{scope.row.date | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}
      </template>
    </el-table-column>
    <el-table-column label="充值次数" width="195" align="center">
      <template slot-scope="scope">
        {{scope.row.count | toThousandslsFilter}}
      </template>
    </el-table-column>
    <el-table-column label="消费金额" width="195" align="center">
      <template slot-scope="scope">
        ¥{{scope.row.price1 | toThousandslsFilter}}
      </template>
    </el-table-column>
    <el-table-column label="最后一次消费时间" width="220" align="center">
      <template slot-scope="scope">
        {{scope.row.date1 | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}
      </template>
    </el-table-column>
    <el-table-column label="是否盈利" width="100" align="center">
      <template slot-scope="scope">
        <el-tag :type="scope.row.status | statusFilter"> {{scope.row.status}}</el-tag>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  //import { fetchList } from '@/api/transaction'

  export default {
    data() {
      return {
        list: null
      }
    },
    filters: {
      statusFilter(status) {
        const statusMap = {
          success: 'success',
          pending: 'danger'
        }
        return statusMap[status]
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      getDate(){
        return new Date()-Math.round(Math.random()*7*24*60*60*1000)
      },
      fetchData() {
        this.list = [
          {order_no: Math.round(Math.random()*100000),name:'尐貓咪咪',price: 20325,date:this.getDate(),count:5,price1:15325,date1:this.getDate(),status: 'success'},
          {order_no: Math.round(Math.random()*100000),name:'____落盡殘殇',price: 18321,date:this.getDate(),count:3,price1:20325,date1:this.getDate(),status: 'pending'},
          {order_no: Math.round(Math.random()*100000),name:'小姑娘',price: 16020,date:this.getDate(),count:3,price1:14223,date1:this.getDate(),status: 'success'},
          {order_no: Math.round(Math.random()*100000),name:'半夏时光',price: 15555,date:this.getDate(),count:8,price1:16325,date1:this.getDate(),status: 'danger'},
          {order_no: Math.round(Math.random()*100000),name:'梦醒时分°',price: 15684,date:this.getDate(),count:2,price1:10325,date1:this.getDate(),status: 'success'},
        ]
        /*fetchList().then(res => {
          this.list = res.items.slice(0, 7)
        })*/
      }

    }

  }
</script>
